﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Docking2010;

namespace ERPClient
{
    public partial class QueryProductForm : Form
    {
        private bool isReady = false;
        public DocumentManager docuManager { set; get;  }

        public QueryProductForm()
        {
            docuManager = null;
            InitializeComponent();
        }

        private void QueryProductForm_Load(object sender, EventArgs e)
        {
            isReady = true;
        }

        private void textEdit1_EditValueChanged(object sender, EventArgs e)
        {
            if (isReady)
            {
                this.bOMViewTableAdapter.FillByID(this.astoolDataSet2.BOMView, Int32.Parse(textEdit1.Text));
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.splashScreenManager1.ShowWaitForm();
            this.productsTableAdapter.FillByID(this.astoolDataSet.Products, QueryEdit.Text);
            this.splashScreenManager1.CloseWaitForm();

            DataRowView row = (DataRowView)gridView1.GetRow(0);
            if (row != null)
            {
                docuManager.GetDocument(this).BeginUpdate();
                docuManager.GetDocument(this).Caption = "產品查詢(" + row["ProductID"].ToString() + ")";
                docuManager.GetDocument(this).EndUpdate();
            }
            
        }

    }
}
